<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>XIUMI connect</title>
    <style>
        html,
        body {
            padding: 0;
            margin: 0;
        }

        #editor135 {
            position: absolute;
            width: 100%;
            height: 100%;
            border: none;
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <iframe id="editor135" src="https://www.135editor.com/beautify_editor.html?callback=true&appkey=">
    </iframe>
    <script type="text/javascript" src="../dialogs/internal.js"></script>
    <script>
        var editor135 = document.getElementById('editor135');
        var editor135_url = "https://www.135editor.com";
        console.log("editor135_url is %o", editor135_url);
        editor135_url.onload = function () {
            console.log("postMessage to %o", editor135_url);
            // "XIUMI:3rdEditor:Connect" 是特定标识符，不能修改，大小写敏感
            editor135_url.contentWindow.postMessage('editor135:3rdEditor:Connect', editor135_url);
        };
        document.addEventListener("mousewheel", function (event) {
            event.preventDefault();
            event.stopPropagation();
        });
        window.addEventListener('message', function (event) {
            console.log("Received message from 135, origin: %o %o", event.origin, editor135_url);
            if (event.origin == editor135_url) {
                console.log("Inserting html");
                editor.execCommand('insertHtml', event.data);
                editor.fireEvent("catchremoteimage");
                console.log("editor135 dialog is closing");
                dialog.close();
            }
        }, false);
    </script>
</body>

</html>